/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EL;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Tian
 */
@Entity
@Table(name = "OrderDetails")
@NamedQueries(
{
    @NamedQuery(name = "OrderDetails.findAll", query = "SELECT o FROM OrderDetails o")
})
public class OrderDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrderDetailsPK orderDetailsPK;
    @Column(name = "deliveryDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deliveryDate;
    @Column(name = "phone")
    private String phone;
    @Column(name = "number")
    private String number;
    @Column(name = "street")
    private String street;
    @Column(name = "ward")
    private String ward;
    @Column(name = "district")
    private String district;
    @Column(name = "city")
    private String city;
    @Column(name = "quantity")
    private Integer quantity;
    @JoinColumn(name = "orderID", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private FoodOrders foodOrders;
    @JoinColumn(name = "foodID", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Foods foods;

    public OrderDetails()
    {
    }

    public OrderDetails(OrderDetailsPK orderDetailsPK)
    {
        this.orderDetailsPK = orderDetailsPK;
    }

    public OrderDetails(String orderID, int foodID)
    {
        this.orderDetailsPK = new OrderDetailsPK(orderID, foodID);
    }

    public OrderDetailsPK getOrderDetailsPK()
    {
        return orderDetailsPK;
    }

    public void setOrderDetailsPK(OrderDetailsPK orderDetailsPK)
    {
        this.orderDetailsPK = orderDetailsPK;
    }

    public Date getDeliveryDate()
    {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate)
    {
        this.deliveryDate = deliveryDate;
    }

    public String getPhone()
    {
        return phone;
    }

    public void setPhone(String phone)
    {
        this.phone = phone;
    }

    public String getNumber()
    {
        return number;
    }

    public void setNumber(String number)
    {
        this.number = number;
    }

    public String getStreet()
    {
        return street;
    }

    public void setStreet(String street)
    {
        this.street = street;
    }

    public String getWard()
    {
        return ward;
    }

    public void setWard(String ward)
    {
        this.ward = ward;
    }

    public String getDistrict()
    {
        return district;
    }

    public void setDistrict(String district)
    {
        this.district = district;
    }

    public String getCity()
    {
        return city;
    }

    public void setCity(String city)
    {
        this.city = city;
    }

    public Integer getQuantity()
    {
        return quantity;
    }

    public void setQuantity(Integer quantity)
    {
        this.quantity = quantity;
    }

    public FoodOrders getFoodOrders()
    {
        return foodOrders;
    }

    public void setFoodOrders(FoodOrders foodOrders)
    {
        this.foodOrders = foodOrders;
    }

    public Foods getFoods()
    {
        return foods;
    }

    public void setFoods(Foods foods)
    {
        this.foods = foods;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (orderDetailsPK != null ? orderDetailsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrderDetails))
        {
            return false;
        }
        OrderDetails other = (OrderDetails) object;
        if ((this.orderDetailsPK == null && other.orderDetailsPK != null) || (this.orderDetailsPK != null && !this.orderDetailsPK.equals(other.orderDetailsPK)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "EL.OrderDetails[orderDetailsPK=" + orderDetailsPK + "]";
    }

}
